Skip to content

feat!: add server discovery and negotiation (SEP-2575)#973

Open
DaleSeo wants to merge 2 commits into
mainfrom
feat/sep-2575-discovery-negotiation
Open

feat!: add server discovery and negotiation (SEP-2575)#973
DaleSeo wants to merge 2 commits into
mainfrom
feat/sep-2575-discovery-negotiation

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Jul 10, 2026

Copy link
Copy Markdown
Member

Motivation and Context

This implements the discovery and negotiation portion of SEP-2575. It adds the server/discover RPC, per-request protocol version negotiation, and typed unsupported-version errors so clients can learn a server's versions and capabilities without initializing a session, while preserving the legacy initialization flow.

All six protocol union enums generated by ts_union! are now #[non_exhaustive]. This requires downstream exhaustive matches to add a wildcard arm once, but allows future protocol variants to be added without causing the same Rust API break.

How Has This Been Tested?

Added tests

Breaking Changes

Yes. ClientRequest, ClientNotification, ClientResult, ServerRequest, ServerNotification, and ServerResult are now #[non_exhaustive], so downstream exhaustive matches must add a wildcard arm. DiscoverRequest and DiscoverResult also add variants to ClientRequest and ServerResult; subsequent variants can be added without another exhaustive-match break.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@DaleSeo DaleSeo self-assigned this Jul 10, 2026
@github-actions github-actions Bot added T-test Testing related changes T-config Configuration file changes T-core Core library changes T-handler Handler implementation changes T-model Model/data structure changes T-service Service layer changes T-transport Transport layer changes labels Jul 10, 2026
@DaleSeo DaleSeo linked an issue Jul 10, 2026 that may be closed by this pull request
6 tasks
@DaleSeo DaleSeo changed the title feat!: add server discovery and negotiation feat!: add server discovery and negotiation [SEP-2575] Jul 10, 2026
@DaleSeo DaleSeo changed the title feat!: add server discovery and negotiation [SEP-2575] feat!: add server discovery and negotiation (SEP-2575) Jul 10, 2026
@DaleSeo DaleSeo linked an issue Jul 10, 2026 that may be closed by this pull request
7 tasks
@DaleSeo DaleSeo marked this pull request as ready for review July 10, 2026 22:08
@DaleSeo DaleSeo requested a review from a team as a code owner July 10, 2026 22:08
@DaleSeo DaleSeo added this to the 2026-07-28 spec milestone Jul 13, 2026
@DaleSeo DaleSeo removed this from the 2026-07-28 spec milestone Jul 13, 2026
@DaleSeo DaleSeo force-pushed the feat/sep-2575-discovery-negotiation branch from 9b9e33a to ce0b7a9 Compare July 14, 2026 14:24
@DaleSeo DaleSeo force-pushed the feat/sep-2575-discovery-negotiation branch from ce0b7a9 to 4071398 Compare July 14, 2026 15:21
Comment thread crates/rmcp/src/model.rs
/// The request used a protocol version the server does not support.
pub const UNSUPPORTED_PROTOCOL_VERSION: Self = Self(-32022);
/// Processing the request requires a client capability that was not declared.
pub const MISSING_REQUIRED_CLIENT_CAPABILITY: Self = Self(-32021);

@DaleSeo DaleSeo Jul 14, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially set them to -32004 and -32003 following the SEP, but it failed the conformance suite. Then, I noticed that the error codes in the SEP differ from the draft schema. I reported this issue in modelcontextprotocol/modelcontextprotocol/issues/3091

  • SEP
Image
  • Schema
Image


/// Select the first client-preferred protocol version supported by the server.
///
/// Returns `None` when no version is shared.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens in this case? When a client only expresses a preference the server doesn't yet support?

Shouldn't it fall back to the newest one the server does support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2026-07-28 T-config Configuration file changes T-core Core library changes T-handler Handler implementation changes T-model Model/data structure changes T-service Service layer changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SEP-2575: Make MCP Stateless

2 participants